package com.ht.medicaltreatment.viewmodel

import com.hjq.http.EasyHttp
import com.hjq.http.listener.OnHttpListener
import com.ht.medicaltreatment.bean.SampleShowListBean
import com.ht.medicaltreatment.bean.SampleShowListPage
import com.ht.medicaltreatment.http.api.SampleShowListAPI

class SampleShowListViewModel:BaseViewModel() {
    fun request(page:Int,list:ArrayList<Int>,onResult:(MutableList<SampleShowListPage>)->Unit){
        EasyHttp.post(this)
            .api(SampleShowListAPI(page, sampleIdList = list))
            .request(object : OnHttpListener<SampleShowListBean>{
                override fun onHttpSuccess(result: SampleShowListBean) {
                    if(result.code == 200){
                        onResult(result.data.pageList)
                    }else{
                        dismissProgress(result.message)
                    }
                }

                override fun onHttpFail(e: Exception) {
                    dismissProgress(e.message!!)
                }
            })
    }
}